#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;  
typedef vector<int> vi;
typedef vector<pii> vp;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=5e5+5;
int n,m,k;

namespace Brute {
  const int N=1005;
  vi b[N];
  bool chk(int x,int y) {
    if(x<1||x>n||y<1||y>m) return 0;
    if(b[x][y]) return 0;
    int al=(x>1?b[x-1][y]:0);
    int ar=(x<n?b[x+1][y]:0);
    int au=(y>1?b[x][y-1]:0);
    int ad=(y<m?b[x][y+1]:0);
    if(al+ar+au+ad>=2) b[x][y]=1;
    return b[x][y];
  }
  void solve() {
    rep(i,1,n) b[i].resize(m+1);
    queue<pii> q;
    rep(i,1,k) {
      int x=read(), y=read();
      b[x][y]=1; q.push(pii(x,y));
    }
    while(!q.empty()) {
      pii pp=q.front(); q.pop();
      int x=pp.fi, y=pp.se;
      if(chk(x-1,y)) q.push(pii(x-1,y));
      if(chk(x+1,y)) q.push(pii(x+1,y));
      if(chk(x,y-1)) q.push(pii(x,y-1));
      if(chk(x,y+1)) q.push(pii(x,y+1));
    }
    int cnt=0;
    rep(i,1,n) rep(j,1,m) cnt+=b[i][j];
    printf("%lld\n",cnt);
  }
}

struct rect {
  int l,r,u,d;
} a[N*2]; bool vst[N*2];
bool chk(rect a,rect b) {
  a.l--, a.r++, a.u--, a.d++;
  b.l--, b.r++, b.u--, b.d++;
  int ml=max(a.l,b.l), mr=min(a.r,b.r);
  int mu=max(a.u,b.u), md=min(a.d,b.d);
  if(ml<=mr&&mu<=md) {
    int sz=(mr-ml+1)*(md-mu+1);
    if(sz<=2) return 0;
    else return 1;
  } else return 0;
}
rect merge(rect a,rect b) {
  return (rect){min(a.l,b.l),max(a.r,b.r),min(a.u,b.u),max(a.d,b.d)};
}


signed main() {
  freopen("grid.in","r",stdin);
  freopen("grid.out","w",stdout);
  n=read(), m=read(), k=read();
  /*
  if(n<=1000&&n*m<=1000000) {
    Brute::solve();
    return 0;
  }
  */
  rep(i,1,k) {
    a[i].l=a[i].r=read();
    a[i].u=a[i].d=read();
  }
  queue<int> q;
  rep(i,1,k) q.push(i);
  int ccc=0;
  while(!q.empty()) {
    int u=q.front(); q.pop();
    if(vst[u]) continue;
    rep(j,1,k) if(j!=u&&!vst[j]) {
      ccc++;
      if(chk(a[u],a[j])) {
        ++k; a[k]=merge(a[u],a[j]);
        q.push(k);
        vst[u]=vst[j]=1;
        break;
      }
    }
  }
  int ans=0;
  rep(i,1,k) if(!vst[i]) ans+=(a[i].r-a[i].l+1)*(a[i].d-a[i].u+1);
  printf("%lld\n",ans);
  return 0;
}